<template>
  <div id="sign" v-if="isShowShiled">
    <div class="bg" @click="hidden" v-if="isShowShiled"></div>
    <div class="modal" v-if="show">
      <div class="modal-top">
        <div class="modal-title">选择屏蔽的标签</div>
        <div class="modal-clear" @click="hidden">
          <img src="../assets/imgs/shanchu.png" alt />
        </div>
      </div>
      <div class="shield-container">
        <div class="shield-Ctn">
       
          <div class="shield-tag" v-for="(item, index) in talkList" :key="index">
            <input type="checkbox" :value="item"  v-model="checkVal"/>
            <label class="auto-span" >#{{item}}</label>
          </div>
        </div>
      </div>

      <div class="sign-btns">
        <div class="pay" @click="shield">确认</div>
        <div class="clear" @click="hidden">取消</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    shieldTalk: {
      type: String,
    },
  },
  data() {
    return {
      modal: [],
      list: [1, 2, 3, 4, 5],
      talkList: [],
      isShowShiled: false,
      talk: "",
      shieldTag: "",
      checkVal:[],
    };
  },
  watch: {
    shieldTalk: {
      handler(newVal, oldVal) {
        if (newVal) {
          this.talkList = newVal.split(",");
        }
      },
    },
  },
  created() {},
  mounted() {
    this.getRem(1920, 100);
  },

  methods: {
    show() {
      this.isShowShiled = true;
    },
    hidden() {
      this.isShowShiled = false;
    },
 
    //屏蔽标签
    shield() {
      let talk  = this.checkVal.join('|');
      if (!talk) {
        this.$message.warning(`请选择屏蔽的标签`);
        return false;
      }
       talk =  talk.replace(/\|/g, "%7C");
      this.$fetch(`/laiwen/hate/frontend/save?hateTalk=${talk}&hateUserId=`).then(
        (res) => {
          //屏蔽成功,隐藏模态窗和刷新列表
          if (res.code == 0) {
            this.$message.success(`屏蔽成功`);
            this.hidden();
            this.$emit('refresh')
          }
        }
      );
    },
  },
};
</script>

<style scoped>
#sign {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  position: absolute;
  left: 0;
  top: 0;
}
img {
  width: 100%;
  height: 100%;
  display: block;
  flex-shrink: 0;
}
.bg {
  width: 100%;
  height: 100%;
  opacity: 0.25;
  background: black;
  position: absolute;
  /* z-index: 2; */
}
.modal {
  width: 5rem;
  height: 5.52rem;
  display: flex;
  align-items: center;
  position: relative;
  flex-direction: column;
  z-index: 9999;
  margin-top: 1.8rem;
  background: white;
  border-radius: 0.05rem;
}
.modalPhone {
  width: 5rem;
  height: 5.52rem;
  display: flex;
  align-items: center;
  position: relative;
  flex-direction: column;
  z-index: 9999;
  background: white;
  border-radius: 0.05rem;
}
.modal .modal-top {
  width: 100%;
  height: 0.79rem;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding-left: 0.32rem;
  position: relative;
  border-bottom: 0.01rem solid #f5f5f5;
}
.modal .modal-top .modal-title {
  height: 0.2rem;
  font-size: 0.18rem;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 0.2rem;
  color: rgba(40, 40, 40, 1);
  opacity: 1;
}
.modal .modal-top .modal-clear {
  width: 0.11rem;
  height: 0.11rem;
  cursor: pointer;
  position: absolute;
  right: 0.32rem;
}
.modal-btns {
  width: 4.35rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 0.72rem;
}
.modal-btns::after {
  content: "";
  width: 0.88rem;
}
.modal .modal-single {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  margin-bottom: 0.24rem;
  width: 1.3rem;
  height: 0.96rem;
  background: rgba(255, 255, 255, 1);
  opacity: 1;
  cursor: pointer;
  border-radius: 0.05rem;
  border: 0.01rem solid transparent;
  background: #eeeeee;
  color: #282828;
}
image {
  width: 100%;
  display: block;
  height: 100%;
}
.modal-text {
  width: 0.42rem;
  height: 0.2rem;
  font-size: 0.14rem;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 0.2rem;
  color: rgba(9, 9, 9, 1);
  opacity: 1;
}
.code {
  margin-top: -0.42rem;
}
.codeCtn {
  width: 100%;
  height: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.WxText {
  font-size: 0.15rem;
  font-family: PingFang SC;
  font-weight: 400;
  color: rgba(9, 9, 9, 1);
  margin-top: 0.12rem;
  opacity: 1;
}
.modal-btn {
  width: 0.88rem;
  height: 0.78rem;
  background: rgba(238, 238, 238, 1);
  opacity: 1;
  border-radius: 0.05rem;
  margin-top: 0.08rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}
.gift-icon {
  font-size: 0.16rem;
}
.modal-btn .gift-icon {
  width: 0.31rem;
  height: 0.31rem;
  margin-top: 0.13rem;
  font-size: 0.16rem;
}
.gift-text {
  margin-top: 0.07rem;
  height: 0.2rem;
  font-size: 0.14rem;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 0.2rem;
  opacity: 1;
}
.sign-btns {
  width: 100%;
  display: flex;
  position: absolute;
  bottom: 0;
  height: 0.84rem;
  align-items: center;
  border-top: 0.01rem solid #f5f5f5;
  justify-content: center;
}
.pay {
  width: 1.22rem;
  height: 0.38rem;
  background: rgba(255, 189, 61, 1);
  opacity: 1;
  border-radius: 0.05rem;
  font-size: 0.14rem;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 0.38rem;
  cursor: pointer;
  text-align: center;
  color: rgba(255, 255, 255, 1);
  opacity: 1;
  outline: none;
  margin-right: 0.2rem;
}
.clear {
  width: 1.22rem;
  height: 0.38rem;
  background: white;
  opacity: 1;
  border-radius: 0.05rem;
  cursor: pointer;
  font-size: 0.14rem;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 0.38rem;
  border: 0.01rem solid rgba(153, 153, 153, 1);
  text-align: center;
  color: #282828;
  opacity: 1;
}
.clear-btn {
  width: 0.24rem;
  height: 0.24rem;
  border-radius: 50%;
  opacity: 1;
  position: absolute;
  right: -0.24rem;
  top: 0.18rem;
  cursor: pointer;
}
.shield-container {
  display: flex;
  height: 3.87rem;
  width: 100%;
  align-items: center;
}
.shield-Ctn {
  display: flex;
  flex-direction: column;
  margin-left: 0.32rem;
}
.shield-tag {
  height: 0.24rem;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
}
.auto-span {
  font-size: 0.17rem;
  font-family: PingFang SC;
  font-weight: 400;
  color: #090909;
  opacity: 1;
  margin-top: 0.02rem;
  margin-left: 0.16rem;
}
input[type="checkbox"] {
  width: 0.2rem;
  height: 0.2rem;
  background: rgba(255, 255, 255, 1);
  opacity: 1;
  display: inline-block;
  outline: none;
  position: relative;
  margin: 0;
  padding: 0;
  cursor: pointer;
  /* //去掉了小蓝角 */
  appearance: none;
}
input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 0;
  text-align: center;
  vertical-align: middle;
  left: 0;
  line-height: 0.2rem;
  background: #fff;
  border-radius: 0.05rem;
  border: 1px solid #d0d0d0;
  width: 0.2rem;
  margin: 0;
  padding: 0;
  height: 0.2rem;
  outline: none;
}
input[type="checkbox"]:checked::before {
  content: "\2713";
  background-color: #ffe300;
  color: #fff;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  outline: none;

  font-weight: bold;
}
</style>
